package com.npave.zryhadapter.response.vo;


import com.npave.zryhadapter.response.ReturnMsg;

import java.io.Serializable;

/**
 * 统一封装json数据对象
 *
 * json格式
     成功
     返回结果
     {code:0000}
     返回数组
     {code:0000,data:[xxx,yyy]}
     返回对象数组
     {code:0000,data:[{xxx:yyy,aaa:bbb}]}
     返回对象
     {code:0000,data:{xxx:yyy}}
     返回对象包含列表(用于分页)
     {code:0000,data:{xxx:yyy,list:[]}}
     eg:分页
     {code:0000,data:{pagesize:8,page:1,totalpage:9,list:[{xxx:yyy,aaa:bbb}]}}
     示例代码：setData(com.lljz.p2p.vo.Page)

     失败
     返回错误
     {code:0001,msg:'xxxx'}
     eg:登录失败
     {code:0001,msg:'登录已失效,请重新登录'}

 * */
public class JsonObj implements Serializable {

    private static final long serialVersionUID = 1943399039469107410L;
    private String            code             = "0000";
    private String            msg;
    private Object            data;

    public JsonObj() {
    }

    public JsonObj(String code, String msg) {
        this.code = code;
        this.msg = msg;
    }

    public JsonObj(ReturnMsg returnMsg) {
        this.setCode(returnMsg.code);
        this.setMsg(returnMsg.msg);
    }

    public void setError(ReturnMsg returnMsg) {
        this.setCode(returnMsg.code);
        this.setMsg(returnMsg.msg);
    }

    public JsonObj(Object data) {
        this.data = data;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

}
